import { Controller, Get, Post, Body, Param, Delete, Put, Query } from '@nestjs/common';
import { Product_Service } from './product.service';
import { Product_Create_Dto, Product_Update_Dto } from './assets/product.dto';
import { Product_Find_Dto, Product_FindAll_Dto } from './assets/product.dto';
import { ApiExtraModels, ApiTags } from '@nestjs/swagger';
import { util_ApiResponse_Base } from '@/common/util/apiResponse';
import { util_Index_ReturnContent } from '@/common/util/index';
import { Class_Index_ListAll } from '@/common/classes/index';

@Controller('/adm/product')
@ApiTags('product 规格管理')
export class Product_Controller {
  constructor(private readonly product_Servicc: Product_Service) {}

  @Post('/add')
  @util_ApiResponse_Base({
    dataType: 'dataType_add',
    //apiKey: '/adm/product/add Post',
  })
  async product_Create(@Body() body: Product_Create_Dto) {
    return util_Index_ReturnContent(await this.product_Servicc.product_Create(body));
  }

  @Get('/list')
  @util_ApiResponse_Base({
    dataType: 'dataType_list',
    //apiKey: '/adm/product/list Get',
  })
  async product_FindByPage(@Query() query: Product_Find_Dto) {
    return util_Index_ReturnContent(await this.product_Servicc.product_FindByPage(query));
  }

  @Get('/listSelect')
  @ApiExtraModels(Class_Index_ListAll)
  @util_ApiResponse_Base({
    dataType: 'dataType_listSelect',
    //apiKey: '/adm/product/listSelect Get',
    type: Class_Index_ListAll,
  })
  async product_FindAllSelect(@Query() query: Product_FindAll_Dto) {
    return util_Index_ReturnContent(await this.product_Servicc.product_FindAllSelect(query));
  }

  @Put('/update')
  @util_ApiResponse_Base({
    dataType: 'dataType_update',
    //apiKey: '/adm/product/update Put',
  })
  async product_Update(@Body() body: Product_Update_Dto) {
    return util_Index_ReturnContent(await this.product_Servicc.product_Update(body));
  }

  @Delete('/delete/:id')
  @util_ApiResponse_Base({
    dataType: 'dataType_delete',
    //apiKey: '/adm/product/delete/:id Delete',
  })
  async product_Remove(@Param('id') id: string) {
    return util_Index_ReturnContent(await this.product_Servicc.product_Remove(+id));
  }
}
